import re

class KeywordsConfig:
    """微博爬虫配置类，管理关键词、请求头和正则表达式等配置"""
    
    def __init__(self):
        # 定义组合关键词的三个维度
        self.scam_types = [
            "钓鱼诈骗", "洗钱", "勒索软件", "资金盘跑路",
            "智能合约漏洞", "虚假空投", "冒充交易所"
        ]
        self.blockchain_terms = [
            "比特币", "以太坊", "TRON", "BNB Chain",
            "Solana", "Polygon", "波场"
        ]
        self.target_terms = [
            "地址", "钱包", "收款码", "资金池",
            "转账记录", "黑名单"
        ]

        # 动态生成组合关键词
        self.keywords = [
            f"{scam} {blockchain} {target}"
            for scam in self.scam_types
            for blockchain in self.blockchain_terms
            for target in self.target_terms
        ]
        
        # HTTP请求头
        self.headers = {
            'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36',
            'Cookie': '请替换为你自己的微博Cookie'
        }
        
        # 微博搜索基础URL
        self.base_url = 'https://s.weibo.com/weibo?q={}&page={}'
        
        # 区块链地址正则表达式
        self.address_pattern = re.compile(
            r'(0x[a-fA-F0-9]{40})|'  # 以太坊地址
            r'(T[1-9A-HJ-NP-Za-km-z]{33})|'  # TRON地址
            r'([13][a-km-zA-HJ-NP-Z1-9]{25,34})|'  # 比特币Legacy/P2SH
            r'(bc1[a-zA-HJ-NP-Z0-9]{25,90})'  # 比特币Bech32（SegWit）
        )
        
        # 爬虫行为配置
        self.retry_count = 3
        self.retry_delay = 5  # 秒
        self.pages_per_keyword = 5
        self.output_file = 'blockchain_addresses.csv'    